package com.hopu.erp.service.impl;

import com.hopu.erp.dao.RoleFunctionDAO;
import com.hopu.erp.entity.RoleFun;
import com.hopu.erp.service.RoleFunctionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class RoleFunctionServiceImpl implements RoleFunctionService {

    @Autowired
    private RoleFunctionDAO roleFunctionDAO;

    @Override
    public String addRoleFunction(RoleFun roleFun) {
        RoleFun roleFun1 = roleFunctionDAO.selectRoleFunction(roleFun);
        if(roleFun1 == null){
            roleFunctionDAO.insertRoleFunction(roleFun);
            return "ok";
        }
        return "exists";
    }

    @Override
    public String removeRoleFunction(RoleFun roleFun) {
        RoleFun roleFun1 = roleFunctionDAO.selectRoleFunction(roleFun);
        if(roleFun1 != null) {
            roleFunctionDAO.deleteRoleFunction(roleFun);
            return "ok";
        }
        return "not exists";
    }

    @Override
    public RoleFun findRoleFunction(RoleFun roleFun) {
        return roleFunctionDAO.selectRoleFunction(roleFun);
    }
}
